<?php

include_once '../recursos.php';

class InicializarLigaPostgres extends PHPUnit_Framework_TestCase {
    
    protected $id = 100;
    protected $idLiga1=1;


    public function tearDown() {
        
    }

     public function testInicializarLigaPostgres() {
        InicializarLiga($this->idLiga1);
        $sql = "select * from is_db.player_league_team where id_league = $this->idLiga1";
        $result = pg_query($sql);
        $lineas = pg_num_rows($result);
        $this->assertEquals(472, $lineas);
     }
    
    public function testAsignarJugadoresAEquiposPostgres() {
        asignarJugadoresAEquipos($this->idLiga1);
        $conn = conectarDb();
        $sql = "select * from is_db.player_league_team where id_team <> 0";
        $result = pg_query($sql);
        $lineas = pg_num_rows($result);
        $sql2 = "select * from is_db.team where id_league = $this->idLiga1";
        $result2 = pg_query($sql2);
        $lineas2 = pg_num_rows($result2);
        $this->assertEquals(15*$lineas2, $lineas);
    }
    
    public function testAsignarJugadoresAMercadoPostgres(){
        obtenerNuevosJugadoresEnVentaEnLiga($this->idLiga1, 15);
        $conn = conectarDb();
        $sql = "select * from is_db.player_league_team where market=1 and id_league=$this->idLiga1";
        $result = pg_query($sql);
        $lineas = pg_num_rows($result);
        $this->assertEquals(15, $lineas);
    }
        
    }
?>
